package com.personal.system.controller.content.web;

import com.personal.common.result.Result;
import com.personal.system.entity.content.Comment;
import com.personal.system.service.content.web.ApiCommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/blog/v1/comment")
@Api(tags = "评论API-V1")
@RequiredArgsConstructor
public class ApiCommentController {

    private final ApiCommentService commentService;

    @RequestMapping(value = "/",method = RequestMethod.POST)
    @ApiOperation(value = "添加评论", httpMethod = "POST", response = Result.class, notes = "添加评论")
    public Result insertComment(@RequestBody Comment comment){
        return commentService.insertComment(comment);
    }

    @RequestMapping(value = "/",method = RequestMethod.GET)
    @ApiOperation(value = "根据文章id获取相关评论", httpMethod = "GET", response = Result.class, notes = "根据文章id获取相关评论")
    public Result selectCommentByArticleId(int pageNo,int pageSize,Long articleId){
        return commentService.selectCommentByArticleId(pageNo,pageSize,articleId);
    }

    @RequestMapping(value = "/getMyComment",method = RequestMethod.GET)
    @ApiOperation(value = "获取我的评论", httpMethod = "GET", response = Result.class, notes = "获取我的评论")
    public Result selectMyComment(){
        return commentService.selectMyComment();
    }
}
